package cn.wetcland.urban.admin.controller;

import cn.wetcland.urban.admin.dto.OpenCityAddDTO;
import cn.wetcland.urban.admin.dto.OpenCityUpdateDTO;
import cn.wetcland.urban.admin.dto.OrderUpdateDTO;
import cn.wetcland.urban.admin.service.UtOpenCityService;
import cn.wetcland.urban.common.AjaxResponse;
import cn.wetcland.urban.generator.domain.UtOpenCity;
import cn.wetcland.urban.generator.domain.UtOrder;
import cn.wetcland.urban.generator.dto.BaseConditionSearchDTO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/openCity")
public class OpenCityController {

    @Resource
    public UtOpenCityService openCityService;

    @GetMapping("/openCityList")
    public AjaxResponse openCityList(BaseConditionSearchDTO searchDTO) {
        Page<UtOpenCity> page = openCityService.openCityList(searchDTO);
        return AjaxResponse.success(page);
    }

    @PutMapping("/openCityUpdate")
    public AjaxResponse openCityUpdate(@RequestBody OpenCityUpdateDTO updateDTO) {
        openCityService.openCityUpdate(updateDTO);
        return AjaxResponse.success();
    }

    @PostMapping("/openCityAdd")
    public AjaxResponse openCityAdd(@RequestBody OpenCityAddDTO addDTO) {
        openCityService.openCityAdd(addDTO);
        return AjaxResponse.success();
    }

    @DeleteMapping("/openCityDelete/{id}")
    public AjaxResponse openCityDelete(@PathVariable Long id) {
        openCityService.openCityDelete(id);
        return AjaxResponse.success();
    }

}
